def bubble_sort(enter):
    i = 0
    j = 1
    while j < len(enter):
        if enter[i] <= enter[j]:
            i += 1
            j += 1
        else:
            n = enter[i]
            enter[i] = enter[j]
            enter[j] = n
            i = 0
            j = 1


def quick_sort(lst, start, end):
    if start >= end:
        return
    # 判断长度是否大于1
    left = start
    right = end
    key = lst[left]
    # key为标准值
    while left < right:
        while left < right and lst[right] > key:
            right -= 1
        lst[left] = lst[right]
        # 将小于标准值的数放空位，一开始标准值为空位，转移后当前下标位置即为空位
        while left < right and lst[left] <= key:
            left += 1
        lst[right] = lst[left]
        # 将大于标准值的数放空位，上步循环右指针所在的下标即为空位
    lst[left] = key
    # 将标准值放入指针交汇点，交汇点左边的数都小于标准值，交汇点右边的数都大于标准值
    quick_sort(lst, left + 1, end)
    # 交汇点右侧继续递归
    quick_sort(lst, start, left - 1)
    # 交汇点左侧继续递归

choice = input('输入1快排，输入2冒泡排序')
if choice == '1':
    lst = input('请输入要排序的数字')
    lst = list(str(lst))
    quick_sort(lst, 0, len(lst) - 1)
    print(lst)
elif choice == '2':
    lst = input('请输入要排序的数字')
    lst = list(str(lst))
    bubble_sort(lst)
    print(lst)
else:
    print('请按提示输入')
